<template>
  <div class="loginMain">
    <h1 class="title">登录</h1>
    <component :is="cnps" ref="accountRef"></component>
    <!-- <Account ref="tt"></Account> -->
    <div class="control-account">
      <el-checkbox v-model="isKeep">记住密码</el-checkbox>
      <el-link>忘记密码</el-link>
    </div>
    <el-button type="primary" class="login-btn" @click="loginAction"
      >登录</el-button
    >
    <el-row justify="space-around" class="login-row">
      <el-col :span="8">
        <hr />
      </el-col>
      <el-col :span="8" style="text-align: center">
        <p>其他登录</p>
      </el-col>
      <el-col :span="8">
        <hr />
      </el-col>
    </el-row>
    <el-row justify="center" class="line">
      <el-button type="primary" @click="cnps = 'account'">
        <el-icon>
          <UserFilled />
        </el-icon>
        <span>账户登录</span>
      </el-button>
      <el-button type="primary" @click="cnps = 'phone'">
        <el-icon>
          <Iphone />
        </el-icon>
        <span>手机登录</span>
      </el-button>
    </el-row>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { UserFilled, Iphone } from '@element-plus/icons-vue';
import Account from './account.vue';
import Phone from './phone.vue';
export default defineComponent({
  components: {
    UserFilled,
    Iphone,
    Account,
    Phone
  },
  setup() {
    const cnps = ref('account');
    const isKeep = ref<boolean>(true);
    const accountRef = ref();

    const loginAction = () => {
      if (cnps.value === 'account') {
        accountRef.value?.accountLoginAction(isKeep.value);
      }
    };
    return {
      isKeep,
      loginAction,
      cnps,
      accountRef
    };
  }
});
</script>

<style lang="scss" scoped>
.loginMain {
  width: 336px;

  .title {
    color: #374151;
    font-weight: 600;
    margin-top: 12px;
    font-size: 24px;
    text-align: center;
  }

  .demo-tabs {
    margin-top: 40px;

    .el-icon {
      vertical-align: -15%;
    }
  }

  .control-account {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
  }

  ::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
    color: #606266;
  }

  .login-row {
    align-items: center;
    margin-top: 28px;

    hr {
      border-radius: 0.375rem;
      border-color: rgb(209 213 219 / 1);
    }

    p {
      color: #4b5563;
      font-weight: 500;
      font-size: 14px;
    }
  }

  .line {
    margin-top: 28px;
  }

  .mt-40 {
    margin-top: 40px;
  }

  .login-btn {
    margin-top: 10px;
    width: 100%;
    background: #3b82f6;
    font-size: 16px;
  }
}
</style>
